import 'package:bruno/bruno.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../AppConfig/Config.dart';

class InvalidList extends StatefulWidget {
  const InvalidList({super.key});

  @override
  State<InvalidList> createState() => _InvalidListState();
}

class _InvalidListState extends State<InvalidList> {
  List dataList=[];
  int pageNum=1;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();

  }
// 模拟加载更多数据的方法
  void onReachBottom() {
    setState(() {
      pageNum=pageNum+1;

    });

    // 在这里可以执行加载更多数据的逻辑
  }


// 模拟加载更多数据的方法
  void _onRefresh() {
    setState(() {
      pageNum=1;

    });

    // 在这里可以执行加载更多数据的逻辑
  }
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return EasyRefresh(
        header:
        ClassicHeader(
          dragText: '下拉刷新',
          armedText: '准备释放',
          readyText: '加载中...',
          processingText: '加载中...',
          processedText: '刷新成功',
          noMoreText: '暂无更多',
          failedText: '刷新失败',
          messageText: '刷新时间 %T',
        ),
        footer: ClassicFooter(
          dragText: '加载更多',
          armedText: '准备释放',
          readyText: '加载中...',
          processingText: '加载中...',
          processedText: '加载成功',
          noMoreText: '暂无更多',
          failedText: '加载失败',
          messageText: '加载时间 %T',
        ),
        onRefresh: _onRefresh,
        onLoad:dataList.length>pageNum*20-1?onReachBottom:null,
        child:
        Container(

            color: Color.fromRGBO(248, 248, 248, 1),
            child:  ListView(

                children: [
                  Container(
                      margin: EdgeInsets.only(top: 8.h),
                      height:screenSize.height-160.h,
                      child:
                      dataList.isNotEmpty?
                      BrnAbnormalStateWidget(
                        img: Image.asset(
                          'lib/Images/OrderList/找货暂无货源.png',
                          scale: 3.0,
                        ),
                        content: '您的账号暂无订单',
                      ): ListView.separated(
                        shrinkWrap:true,
                        itemCount: 3,
                        itemBuilder: (BuildContext context, int index) {
                          return GestureDetector(
                            child: Container(
                              margin: EdgeInsets.only(left: 8.w,right: 8.w),
                              padding: EdgeInsets.only(top: 10.h,right: 10.w,bottom: 10.h,left: 10.w),
                              decoration: BoxDecoration(
                                  color: Colors.white,
                                  borderRadius: BorderRadius.all(Radius.circular(10))),
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Row(
                                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                    children: [
                                      Text("YD123456",style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
                                      Text("苏州速搜物流科技有限公司",style: TextStyle(color: MyColors.textColor,fontSize: 11.sp),),
                                    ],
                                  ),
                                  SizedBox(height: 4.h,),
                                  Text("未指定客户",style: TextStyle(color: Colors.black,fontSize: 14.sp,fontWeight: FontWeight.w600),),
                                  SizedBox(height: 4.h,),
                                  Text("床单丨纸箱丨10吨",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                                  SizedBox(height: 4.h,),
                                  Row(
                                    children: [
                                      Image.asset("lib/Images/OrderList/装icon.png",width: 13.w,height: 13.h,),
                                      SizedBox(width: 4.w,),
                                      Container(
                                        constraints: BoxConstraints(
                                          maxWidth:screenSize.width-60.w,

                                        ),
                                        child:   Text("江苏省苏州市吴中区展业路",style: TextStyle(color: Colors.black,fontSize: 13.sp),overflow: TextOverflow.ellipsis,),
                                      ),

                                    ],
                                  ),
                                  Image.asset("lib/Images/OrderList/垂直虚线.png",width:13.w ,height:8.h,),
                                  Row(
                                    children: [
                                      Image.asset("lib/Images/OrderList/装icon.png",width: 13.w,height: 13.h,),
                                      SizedBox(width: 4.w,),
                                      Container(
                                        constraints: BoxConstraints(
                                          maxWidth:screenSize.width-60.w,

                                        ),
                                        child:   Text("江苏省苏州市吴中区展业路",style: TextStyle(color: Colors.black,fontSize: 13.sp),overflow: TextOverflow.ellipsis,),
                                      ),

                                    ],
                                  ),
                                  Image.asset("lib/Images/OrderList/垂直虚线.png",width:13.w ,height:8.h,),
                                  Row(
                                    children: [
                                      Image.asset("lib/Images/OrderList/卸icon.png",width: 13.w,height: 13.h,),
                                      SizedBox(width: 4.w,),
                                      Container(
                                        constraints: BoxConstraints(
                                          maxWidth:screenSize.width-60.w,

                                        ),
                                        child:   Text("江苏省苏州市吴中区展业路",style: TextStyle(color: Colors.black,fontSize: 13.sp),overflow: TextOverflow.ellipsis,),
                                      ),

                                    ],
                                  ),
                                  Image.asset("lib/Images/OrderList/垂直虚线.png",width:13.w ,height:8.h,),
                                  Row(
                                    children: [
                                      Image.asset("lib/Images/OrderList/卸icon.png",width: 13.w,height: 13.h,),
                                      SizedBox(width: 4.w,),
                                      Container(
                                        constraints: BoxConstraints(
                                          maxWidth:screenSize.width-60.w,
                                        ),
                                        child:   Text("江苏省苏州市吴中区展业路",style: TextStyle(color: Colors.black,fontSize: 13.sp),overflow: TextOverflow.ellipsis,),
                                      ),

                                    ],
                                  ),
                                  Divider(height: 20.h,color: MyColors.backgreyColor,),

                                  Row(
                                    mainAxisAlignment: MainAxisAlignment.end,
                                    children: [


                                      GestureDetector(
                                        child:   BrnTagCustom.buildBorderTag(
                                          tagText: '再发一单',
                                          textColor:  MyColors.themeColor,
                                          borderColor: MyColors.themeColor,
                                          borderWidth: 1,
                                          fontSize: 13.sp,
                                          tagBorderRadius:BorderRadius.all(Radius.circular(30)),
                                          textPadding: EdgeInsets.only(left: 10.w,right: 10.w,top: 2.h,bottom: 2.h),
                                        ),
                                      ),

                                    ],
                                  )
                                ],
                              ),
                            ),
                          );
                        },  separatorBuilder: (context, index) { //自定义分割线
                        return   Container(
                          height: 8.h,
                        );
                      },
                      )
                  )
                ]
            )
        )
    );
  }
}
